<template>
  <div>
    <!-- 面包屑 -->
    <Breadcrumb :crumbs='crumbs'/>
    <!-- 数据区域 -->
    <el-card class="box-card">
      <el-row>
        <el-table stripe border style='width:100%' :data="rights">
          <el-table-column type='index' label='#'></el-table-column>
          <el-table-column prop="authName" label="权限名称"></el-table-column>
          <el-table-column prop="path" label="路径"></el-table-column>
          <el-table-column prop="level" label="权限等级">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.level == 0" type="primary">一级</el-tag>
              <el-tag v-else-if="scope.row.level == 1" type="success">二级</el-tag>
              <el-tag v-else-if="scope.row.level == 2" type="warning">三级</el-tag>
            </template>
          </el-table-column>
        </el-table>
      </el-row>
    </el-card>
  </div>
</template>

<script>
import Breadcrumb from '../Breadcrumb.vue'

export default {
  components: { Breadcrumb },
  data () {
    return {
      crumbs: [
        { path: '/home', title: '首页' },
        { title: '权限管理' },
        { title: '权限列表' }
      ],
      rights: []
    }
  },
  methods: {
    async getRightsList () {
      const { data: res } = await this.axios.get('private/v1/rights/list')
      console.log('getRights res:', res)
      if (!res || !res.meta || res.meta.status !== 200) return this.$message.error('获取权限列表失败')
      this.rights = res.data
    },
    handlerQuery () {
      console.log('query')
    }
  },
  created () {
    this.getRightsList()
  }
}
</script>

<style lang="less" scoped>
.box-card {
  margin: 10px;
}

.el-row {
  margin-bottom: 20px;
}
</style>
